<div class='topic_list_container'>
    {% for one in topic_list %}
        {% if one.id %}
            <div class='topic_list'>
                <a href="{%url unblog_topic one.id %}">
                <h2>{{ one }}</h2>
                <div name='topic_preview'>
                    {% for post in one.unblog_set.all|slice:":8" %}
                        <div class='item_info'> 
                            {{ post.text|slice:":20" }}{% if post.text|length > 17 %}...{% endif %}
                            <i>{{ post.user.userprofile }}</i>
                        </div>
                    {% endfor %}
                </div>
                </a>
            </div>
        {% endif %}
    {% endfor %}
</div>
<script type='text/javascript'>
function switch_topic_preview() {
    els = document.getElementsByName('topic_preview');
    for (i in els) {
        if (els[i].style) {
            if (els[i].style.display!='none') { els[i].style.display='none'; } else { els[i].style.display='block'; };
        };
    };
}
</script>